#include "FSMMgr.h"
#include "StateFactory.h"

//-------------------------------------------------------------------------
bool_t CFSMMgr::Update()
{
	bool_t bFinish = true;

	if(m_pStateRoot.IsValid())
	{
		m_stateResult.Clear();
		m_pStateRoot->OnUpdate(&m_stateResult);

		for(u32_t i = 0; i < m_stateResult.GetNumActions(); i++)
		{
			CActionPtr pAction = m_stateResult.GetAction(i);
			pAction->Execute();
		}
	}

	return bFinish;
}

//-------------------------------------------------------------------------
void CFSMMgr::Build(const CStateGraphDataPtr &data)
{
	m_pStateRoot = CStateFactory::Create(data);
}

//-------------------------------------------------------------------------
void CFSMMgr::SetStateGraph(CStateGraph *pStateGraph)
{
	m_pStateRoot = pStateGraph;
}